-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes #4334: sphinx-apidoc: References to non-existing files in TOC #4335
Closes #4334: sphinx-apidoc: References to non-existing files in TOC #4335
Conversation
@@ -116,7 +116,12 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs, is_ | |||
text += '\n' | |||
|
|||
# build a list of directories that are szvpackages (contain an INITPY file) | |||
subs = [sub for sub in subs if path.isfile(path.join(root, sub, INITPY))] | |||
# and also checks the INITPY file is not empty, or there are other python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an empty INITPY is still a valid INITPY making the directory a package as opposed to namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. But before this patch there would be a reference to that package, although the package .rst file would never be created. It seems to have been the behaviour of apidoc.py since many years to exclude those packages.
See:
Lines 159 to 169 in 87cebf1
if INITPY in py_files: | |
# we are in package ... | |
if (# ... with subpackage(s) | |
subs | |
or | |
# ... with some module(s) | |
len(py_files) > 1 | |
or | |
# ... with a not-to-be-skipped INITPY file | |
not shall_skip(path.join(root, INITPY)) | |
): |
That's why I'm reluctant to change an existing deliberate design, but tried to fix the inconsistency. If we change the behaviour in apidoc.py to not skip empty init.py files in shall_skip it'd still be consistent. @birkenfeld ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also feel the skip for empty __init__.py
is strange. But it is the default behavior of apidoc. So let's keep this as is. :-p
Thank you for contribution! |
Subject: Don't generate references to non-existing files in in TOC of python packages or modules
Feature or Bugfix
Purpose
Detail
Relates